<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <%@include file="/common/common.jsp" %>
</head>
<body>
<div class="right-container">
	<div class="manage-button text-left">
        <button id="completeBtn" class="btn btn-primary" type="button">
            <i class="fa fa-pencil"></i>&nbsp;完成任务
        </button>
        <button id="taskPicBtn" class="btn btn-primary" type="button">
            <i class="fa fa-pencil"></i>&nbsp;任务分配分布图
        </button>
    </div>
    
    <div class="row">
        <div class="col-xs-12">
            <table id="grid-table"></table>
            <div id="grid-pager"></div>
        </div>
    </div>
</div>

<!-- page specific plugin scripts -->
<script src="${basePath}/plugins/jqGrid/jquery.jqGrid.min.js${VERSION}"></script>
<script src="${basePath}/plugins/jqGrid/grid.locale-cn.js${VERSION}"></script>

<!-- inline scripts related to this page -->
<script type="text/javascript">
    var roleName;
    var roleId;
    var taskId = ${taskId};
    var alloterId = ${alloterId};
    //alert("${basePath}/userTask/findUserTasks?taskId="+${taskId});
    jQuery(function ($) {
        CommonUtils.grid({
            url: "${basePath}/userTask/anon/findUserTasks?taskId="+taskId,
            colNames: ['序号','被分配人','被分配人', '计划开始时间','实际开始时间', '计划结束时间','实际结束时间','创建时间'],
            colModel: [
                {name: 'userTaskId', index: 'id', key: true, width: 30, sorttype: "int"},
                {
                    name: 'userName',
                    index: 'userName',
                    width: 40
                },
                {
                    name: 'alloterId',
                    index: 'alloterId',
                    width: 40,
                    hidden:true
                },
                {
                    name: 'startTimePl',
                    index: 'startTimePl',
                    width: 70,
                    formatter: CommonUtils.formateDay
                },
                {
                    name: 'startTimeReal',
                    index: 'startTimeReal',
                    width: 70,
                    
                    formatter: CommonUtils.formateDay
                },
                {
                    name: 'endTimePl',
                    index: 'endTimePl',
                    width: 70,
                    formatter: CommonUtils.formateDay
                },
                {
                    name: 'endTimeReal',
                    index: 'endTimeReal',
                    width: 70,
                    formatter: CommonUtils.formateDay
                },
                {
                    name: 'createTime',
                    index: 'createTime',
                    width: 90,
                    formatter: CommonUtils.formateDate
                }
            ],
            multiselect: true,
            multiboxonly:false,
            onSelectRow: function(id){
                roleName = $("#grid-table").jqGrid('getRowData',id).roleName;
                roleId = $("#grid-table").jqGrid('getRowData',id).roleId
            }
        });
        $('#grid-table').setGridHeight("180px");
        
        $("#completeBtn").click(function () {
            query();
        });

        function query() {
        	var rowId_t = $("#grid-table").jqGrid('getGridParam', 'selarrrow');
        	if (rowId_t.length > 1  || rowId_t == "") {
                layer.msg("请选择一行数据进行完成！");
                return;
            }
        	var rowData = $("#grid-table").jqGrid('getRowData', rowId_t);
        	if(rowData.alloterId!=alloterId){
        		layer.msg("请选择分配自己的行数据进行完成！");
                return;
        	}
        	
			var userTaskId = rowData.userTaskId;
			
            pageii = layer.open({
                title: "任务信息修改",
                type: 2,
                maxmin: true,
                area: ["800px", "600px"],
                content: '${basePath}/userTask/update?userTaskId='+userTaskId
            });
        };
        
        
        
        $("#taskPicBtn").click(function () {
            pageii = layer.open({
                title: "任务分配图",
                type: 2,
                maxmin: true,
                area: ["1000px", "600px"],
                content: '${basePath}/userTask/fish?taskId='+taskId
            });
        });
        
    });
    
</script>
</body>
</html>